package com.android.multiplesmart.websocket;

import android.util.Log;

import com.android.multiplesmart.utils.HandlersUtils;
import com.schillerchina.baselibrary.constans.AppConstants;
import com.schillerchina.baselibrary.utils.Pref;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

/**
 * @author zhangzhiguo
 * @date 2019-08-01 09:27
 * @Description: JWebSocketClient
 */
public class JWebSocketClient extends WebSocketClient {


    public JWebSocketClient(URI serverUri ) {
        super(serverUri, new Draft_6455());

    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        Log.e("JWebSocketClientService", handshakedata.hashCode()+"onOpen() 47300675");
        Pref.put(AppConstants.hashCode,String.valueOf(handshakedata.hashCode()));
        System.out.println("打开了");


    }

    @Override
    public void onMessage(String message) {

        Log.e("JWebSocketClientService", "onMessage()");
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
//        Log.e("JWebSocketClientService", "onClose()");
        Log.e("JWebSocketClientService", code+"");

    }

    @Override
    public void onError(Exception ex) {
        Log.e("JWebSocketClientService", "onError()"+ex.toString());
    }




}




